﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

// GameMap.cs
// The layout of the backdrop for any place that is represented in the game world.
namespace RTS_RPG
{
    public class GameMap
    {
        // GameMap's Fields
        public Texture2D backdrop;
        public Vector2 size;
        //public List<Overworld_Creature> creatures; // for dungeons ?
        //private List<NPC> npcs;
        private List<Block> blocks;
        private Vector2 origin;

        // Constructor
        public GameMap(Texture2D _backdrop, Vector2 _size, List<Block> _blocks)
        {
            backdrop = _backdrop;
            size = _size;
            //creatures = null;
            blocks = _blocks;
            origin = new Vector2(0, 0);
        }

        public void draw(SpriteBatch spBatch, GraphicsDevice graphics_dev)
        {
            //graphics_dev.Clear(Color.Violet);
            //spBatch.Draw(backdrop, origin, Color.White);
            if (blocks == null) return;
            foreach (Block block in blocks)
            {
                block.draw(spBatch);
            }
        }

        // Returns true if there is a collision between the specified 'other' and a block
        public Boolean collision(Vector2 other_location, short other_half_size)
        {
            foreach (Block block in blocks)
            {
                if (block.collision(other_location, other_half_size)) 
                    return true;
            }
            return false;
        }
    }
}
